package com.xiaoyun.collector.controller;

import com.xiaoyun.collector.util.InputMDC;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class IndexController {

    /**
     * [%d{yyyy-MM-dd'T'HH:mm:ss.SSSZZ}] [%level{length=5}] [%thread-%tid] [%logger] [%X{hostName}] [%X{ip}] [%X{applicationName}] [%F,%L,%C,%M] [%m] ## '%ex'%n
     *
     * @return
     */
    @GetMapping("index")
    public String index() {
        InputMDC.putMDC();
        log.info("info");
        log.warn("warn");
        log.error("error");
        return "idx";
    }

    @GetMapping("err")
    public String err() {
        InputMDC.putMDC();
        try {
            int a = 1 / 0;
        } catch (Exception e) {
            log.error("算数异常:{}", e);
        }
        return "err";
    }
}
